import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "./assets/scss/icon/iconfont.css";
import VueAwesomeSwiper from "vue-awesome-swiper";
import "swiper/dist/css/swiper.css";
import axios from "axios";
import "./assets/js/rem";
Vue.use(VueAwesomeSwiper);
Vue.use(axios);
Vue.config.productionTip = false;

Vue.prototype.ajax = (url, obj) => {
  var data = obj.data ? obj.data : {};
  // eslint-disable-next-line no-undef
  axios({
    method: "POST",
    url: "/index/" + url,
    data: data,
    headers: {
      "Content-Type": "application/json",
      "x-requested-with": "XMLHttpRequest"
    }
  })
    .then(res => {
      res = res.data;
      obj.success(res);
    })
    // eslint-disable-next-line no-unused-vars
    .catch(err => {
      obj.error && obj.error();
      // console.log(err)
    })
    // eslint-disable-next-line no-unused-vars
    .catch(e => {
      // eslint-disable-next-line no-undef
      ElementUI.Message.error("网络错误");
    });
};
router.afterEach(() => {
  window.scrollTo(0, 0);
});
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
